package com.hxzy.config;

import com.hxzy.interceptor.LoginCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author wzm
 * @create 2023-10-13 14:50
 * project_name:stu_sys
 */
@Configuration   //标识当前类是一个配置类 里面的方法才会器作用
public class WebConfig implements WebMvcConfigurer {
    //注意我们自己定义的拦截器对象
    @Autowired
    private LoginCheckInterceptor loginCheckInterceptor;

    //注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加拦截器              设置拦截路径 /**表示拦截所有请求controller的路径
        registry.addInterceptor(loginCheckInterceptor).addPathPatterns("/**")
                .excludePathPatterns("/login");//排除不拦截的路径
    }
}
